/*
 * @Descripttion: 
 * @version: 
 * @Author: turingchang
 * @Date: 2020-12-16 11:14:48
 * @LastEditors: turingchang
 * @LastEditTime: 2020-12-29 12:21:45
 */

'use strict';


const BaseController = require('./base/base');

class TestController extends BaseController {

  async index() {
    let d ={
      id: '4bsi8hojycf45ubl6o',
      createAt: 1609205281343,
      updateAt: '2020-12-29 09:27:01',
      workno: null,
      appkey: '31b829f6cb450',
      android: {
          fetchNum: 1,
          deliverNum: 1,
          deliverFailNum: 0,
          reportNum: 1,
          reportFailNum: 0,
          clickNum: 0
      },
      ios: null,
      factory: {
          fetchNum: 1,
          deliverNum: 1,
          deliverFailNum: 0,
          reportNum: 1,
          reportFailNum: 0,
          clickNum: 0
      },
      mobpush: {
          fetchNum: 0,
          deliverNum: 0,
          deliverFailNum: 0,
          reportNum: 0,
          reportFailNum: 0,
          clickNum: 0
      },
      iostcp: null,
      androidtcp: null,
      guard: {
          fetchNum: 0,
          deliverNum: 0,
          deliverFailNum: 0,
          reportNum: 0,
          reportFailNum: 0,
          clickNum: 0
      },
      apns: null,
      huawei: null,
      xiaomi: {
          fetchNum: 1,
          deliverNum: 1,
          deliverFailNum: 0,
          reportNum: 1,
          reportFailNum: 0,
          clickNum: 0
      },
      flyme: null,
      fcm: null,
      oppo: null,
      vivo: null,
      offlineIos: null,
      offlineAndroid: null,
      offlineDrop: null,
      offlineVivo: null,
      sms: {
          fetchNum: 0,
          deliverNum: 0,
          deliverFailNum: 0,
          reportNum: 0,
          reportFailNum: 0,
          clickNum: 0
      },
      enumMethods: {
          xiaomi: {},
          factory: {},
          offlineVivo: {},
          android: {},
          guard: {},
          androidtcp: {},
          iostcp: {},
          ios: {},
          offlineAndroid: {},
          mobpush: {},
          huawei: {},
          fcm: {},
          offlineDrop: {},
          oppo: {},
          offlineIos: {},
          sms: {},
          apns: {},
          flyme: {},
          vivo: {}
      }
    };    
    let json = JSON.stringify(d);
    console.log(111,json);
    this.ctx.outSuccess('', d); 
    //this.ctx.redirect('../../index.html');
  }

  async test() {
    var data = {
      name: 'uuuuuuu',
      pwd: 'adsfafafasd',
      gg: null,
      jj: undefined,
      h: {},
      ro: {
        xxx: 0,
        ccc: null
      }
    };
    // var data = this.app.utils.time.getTimeSpan();   
    //var data =this.app.utils.generator.avatars('书',null,null,null);
    //var data =this.app.utils.generator.generateUid(false);   
    //var data = this.app.utils.string.zhmoney.cn.toMoney(1);   
    //data = this.app.utils.string.pinyin.convert('QQQQ这是一个汉语拼音库',0, false, false, ' ');
    //data =this.app.utils.generator.svgCaptcha.create();    
    //data ==this.app.utils.emoji[0];
    //data = this.app.utils.string.encode(this.app.utils.emoji[0]);
    //var time ='2020-08-24 23:36:10';
    //data =this.app.utils.time.formatMoment(time);
    //var arr =[1,2,3,4,2,6,4];
    //data = this.app.utils.array.deduplication(arr);
    //this.app.getLogger('requestLogger').info(data);
    //this.app.getLogger('requestLogger').debug(data);
    //this.app.logger.info('666666');
    //this.ctx.requestLogger.error(data,'error info me ');
    //console.log(this.ctx.app.config.hasOwnProperty(jwt));
    //console.log(this.ctx.app.config[jwt]);
    //console.log('彩虹屁的彩虹屁'.rainbow);
    // console.log(this.ctx.app.utils.number.formatCurrency(33.84978));
    // console.log(this.ctx.app.utils.number.format(33,2));
    // console.log(111,typeof data);
    // var value ='0014ewtsdg';
    // var pattern = /^[a-z0-9]{4,20}$/;
    // if (pattern.test(value)) {
    //   console.log('yes');
    // }else{
    //   console.log('no');
    // }

    // var s = admin2020;
    // s = this.ctx.app.utils.md5.md5(s);
    // console.log(66666,s);

    // var s = 2020-10;
    // s = this.ctx.app.utils.validator.isDate(s);
    // console.log(66666,s);

    var s = this.ctx.app.adadadd;

    this.ctx.outSuccess(s, data);
  }

  async testPush(){
    var ctx =this.ctx;
    var mobpush = ctx.app.mobpush;
    var uuid = ctx.app.utils.generator.uid();
    var d = await mobpush.push({
      workNo: uuid,
      pushNotify: {
        content: ' test content ',
        title: ' 今日推送测试',
        plats:[1],
      },
      pushTarget: {
        target: ctx.app.enums.mobpush_target_type.alias.value,
        alias:['3939748'],
      },
      pushForward:{
        nextType:ctx.app.enums.mobpush_forward_next_type.link.value,
        url:'https://zhuanlan.zhihu.com/p/336246244',
      }
    });
    this.ctx.outSuccess(uuid, d); 
  }


}

module.exports = TestController;
